import React from 'react';

class Demo extends React.Component {
  state = {
    a: 0,
    b: 1,
    list: [0, 1],
  };

  componentDidMount(){
    setInterval (() => {
      const {a,b,list} = this.state
      const nestB = a + b
      this.setState({
        a : b,
        b : nestB,
        list : [...list, nestB]
      })
    },5000)
  }

  render() {
    return <p>{this.state.list.join(', ')}</p>;
  }
}

export default Demo;
